<template>
  <div>
    <pulldown header="个人身份信息">
      <div slot="content">
        <a-descriptions bordered :column="3">
<!--          <a-descriptions-item v-for="(item,index) of  forList" :key="index" :label="item.name" :span="item.span">-->
<!--            {{ resultData[item.key] }}-->
<!--          </a-descriptions-item>-->
          <a-descriptions-item v-for="(item,index) of forList" :key="index" :label="item.name" :span="item.span">
            {{ item.dictCode ? getDictCode(item.dictCode,resultData[item.key]):resultData[item.key] }}
          </a-descriptions-item>
        </a-descriptions>
      </div>
    </pulldown>
    <pulldown header="家属情况">
      <div slot="content">
        <z-table
          ref="table"
          rowKey="id"
          :showAlert="false"
          :showSelection="false"
          :loading="loading"
          :columns="columns"
          :dataSource="pageData"
          @selectedRow="onSelectedRow"
          @change="onTableChange"
        >
        </z-table>
      </div>
    </pulldown>
    <pulldown header="居住位置图">
      <div slot="content">
        <a-descriptions bordered :column="4">
          <a-descriptions-item v-for="(item,index) of  forList1" :key="index" :label="item.name" :span="item.span">
            {{ item.val }}
          </a-descriptions-item>
        </a-descriptions>
      </div>
    </pulldown>
    <!--    {{$filterDictTextByCache('process_approval_type', 1)}}-->
  </div>
</template>

<script>
import pulldown from '../../../modules/pulldown'
import {basicDetail, Families} from "@api/sjsk/archives";


export default {
  name: "basicOne",
  components:{ pulldown },
  data(){
    return   {
      resultData:{},
      innse:true,
      forList:[
        {name:'证件类型',key:'certificateType',val:'2022.07.14',codeText:'',dictCode:'other_certificate_type'},
        {name:'证件号码',key:'identityCard',val:'张三'},
        {name:'出生日期',key:'birthday',val:'女'},
        {name:'姓名',key:'realName',val:'2022.07.14'},
        {name:'民族',key:'nation',val:'61KG',dictCode:'nation'},
        {name:'性别',key:'sex',val:'171cm',dictCode:'sex'},
        {name:'绰号/别名',key:'nickName',val:'海南海口'},
        {name:'身高（cm）',key:'height',val:'O型'},
        {name:'联系方式',key:'phone',val:'汉族'},
        {name:'婚姻状况',key:'marriage',val:'共青团员',dictCode:'matrimony_type'},
        {name:'从业状况',key:'occupation',val:'健康', dictCode:'work_situation'},
        {name:'文化程度',key:'education',val:'未婚',dictCode:'degreeEducation'},
        {name:'户籍地',key:'householdTown',val:'本科'},
        {name:'户籍地详址',key:'householdAddress',val:'中国医科大学'},
        {name:'户籍地派出所',key:'householdPoliceStation',val:'2022.07.14'},
        {name:'居住地派出所',key:'currentPoliceStation',val:'2022.07.14'}
      ],
      forList1:[
        {name:'居住位置图',key:'date',val:'2022.07.14'},
        {name:'居住地房屋图片',key:'name',val:'禁毒部门'},
        {name:'备注',key:'date',val:'林敏',span:4},
      ],
      loading: false,
      columns: [
        // {
        //   title: '序号',
        //   dataIndex: 'order',
        //   width: 60,
        //   align: 'center',
        //   customRender: (text, record, index) => {
        //     return `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        //   }
        // },
        {
          title: '姓名',
          dataIndex: 'name',
          width: 60,
          align: 'center',
          customRender: text => {
            return <j-ellipsis value={text} length={14} />
          }
        },
        {
          title: '家属关系',
          dataIndex: 'relativesRelation',
          width: 110,
          align: 'left',
          customRender: text => {
            return <j-ellipsis value={text} length={20} />
          }
        },
        {
          title: '家属电话',
          dataIndex: 'phone',
          width: 80,
          align: 'center'
        },
        {
          title: '家属实际居住地',
          dataIndex: 'address',
          width: 100,
          align: 'center',
          customRender: text => {
            return <j-ellipsis value={text} length={14} />
          }
        },
        {
          title: '家属工作单位',
          dataIndex: 'workUnit',
          width: 80,
          align: 'center'
        },
        // {
        //   title: '操作',
        //   width: 120,
        //   align: 'center',
        //   dataIndex: 'action',
        //   scopedSlots: { customRender: 'action' },
        // }
      ],
      pageFilter: {
        pageNo: 1,
        pageSize: 10
      },
      pageData:[],
    }
  },
  computed:{
    sjskId(){
      return this.$store.state.holographicArchives.routeObjData.sjskId
    },
    sjskCode(){
      return this.$store.state.holographicArchives.routeObjData.sjskCode
    }
  },
  methods:{
    getDictCode(key, val) {
      return this.$filterDictTextByCache(key, val)
    },
    refreshTable(val){
      this.getbasicDetail()
      console.log(this.sjskCode)
      console.log(this.sjskId)
      basicDetail({basePersonId:this.sjskId}).then(ser => {
        console.log(ser)
        if(ser.success){
          console.log(ser)
          this.resultData = ser.result
          this.$emit('basicOneD',this.resultData)
          this.$store.dispatch('holographicArchivesFun',this.resultData)
        }
      }).catch(err =>{

      })

    },
    getbasicDetail(){
      Families({basePersonId:String(this.sjskId)}).then(ser => {
        console.log(ser)
        if(ser.success){
          this.pageData = ser.result
          console.log(this.pageData)
          console.log(6)

        }
      }).catch(err => {

      })
    },
    onSelectedRow(keys) {
      this.selectKeys = keys
      this.isDisabled = keys.length > 0 ? false : true
    },
    onTableChange(pagination, pageFilter, sorter) {
      let keyMap = { currentPage: 'pageNo' }
      let paginations = Object.keys(pagination).reduce((newData, key) => {
        let newKey = keyMap[key] || key
        newData[newKey] = pagination[key]
        return newData
      }, {})
      this.pageFilter = Object.assign({}, this.pageFilter, paginations)
      this.getbasicDetail()
    },
  }
}
</script>

<style scoped>

</style>